<div><label>文件内容分析结果:</label></div>
<span>&nbsp</span>
<div>
    <span class="col-sm-2 control-label">sheet中数据行数:</span>
    <div class="col-sm-10">
        <input type="text" style="width:300px;" name="args" class="form-control" readonly value="{{ total_count }}">
    </div>
</div>
<span>&nbsp</span>
<div>
    <span class="col-sm-2 control-label">包含的所有特殊字符:</span>
    <div class="col-sm-10">
        <input type="text" style="width:300px;" name="args" class="form-control" readonly value="{{ special_str }}">
    </div>
</div>
<span>&nbsp</span>
<div>
    <span class="col-sm-2 control-label">字段两头包含的特殊字符:</span>
    <div class="col-sm-10">
        <input type="text" style="width:300px;" name="args" class="form-control" readonly
               value="{{ special_str_side }}">
    </div>
</div>
<span>&nbsp</span>
<div><label>文件内容处理:</label></div>
<span>&nbsp</span>
<div>
    <span class="col-sm-2 control-label">请选择字段分隔符:</span>
    <select class="form-control " style="width:300px" name="cut_str" id="cut_str">
        <option id="def">--请选择分割符--</option>
        {% for i in valid_str %}
            <option id="a">{{ i }}</option>
        {% endfor %}
    </select>
</div>
<span>&nbsp</span>
<div>
    <span class="col-sm-2 control-label">请选择字段包裹符:</span>
    <select class="form-control " style="width:300px" name="quote_str" id="quote_str">
        <option id="def">--请选择包裹符--</option>
        {% for i in valid_str %}
            <option id="a">{{ i }}</option>
        {% endfor %}
    </select>
</div>
<span>&nbsp</span>
<div>
    <span class="col-sm-2 control-label">是否存在表头:</span>
    <select class="form-control " style="width:300px" name="head_str" id="head_str">
        <option id="def">--请选择是否存在表头--</option>
        <option id="a">是</option>
        <option id="a">否</option>
    </select>
</div>
<span>&nbsp</span>
<span>&nbsp</span>
<div style="position:absolute;left:50px;">
    <button type="button" class="btn btn-primary" id="manual_format"> 手工格式化</button>
    <button type="button" class="btn btn-primary " id="convert_csv"> 转成csv</button>
</div>
<div>&nbsp</div>

<script>
    $('#convert_csv').click(function () {
        console.log('convert_csv')
        $.ajax({
            type: "POST",
            data: {
                'file_name': $('#file_parse').val(),
                'sheet_name': $('#sheet_list').val()
            },
            url: "/oratk_app/oratk_most_sqlldr_convert_csv_ajax", //后台处理函数的url
            cache: false,
            dataType: "html",
            beforeSend: function () {
                // $('#loadingModal').modal({backdrop: 'static', keyboard: false});
                showLoading()
                //$('#submit_id').button('loading')
            },
            complete: function () {
                //$('#loadingModal').modal('hide');
                hideLoading()
                //$('#submit_id').button('reset')
            },
            success: function (result) {
                if (result === 'ok') {
                    location.reload();
                } else {
                    alert('转成CSV格式出错，ERROR:\n' +
                        result);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest.status);
                alert(XMLHttpRequest.readyState);
                alert(textStatus);
            },
        })

    })
    $('#manual_format').click(function () {
        var cut_str_id = $('#cut_str').find("option:checked").attr("id")
            if (cut_str_id == 'def') {
                alert('请选择分隔符')
                return false;
            }
            var quote_str_id = $('#quote_str').find("option:checked").attr("id")
            if (quote_str_id == 'def') {
                alert('请选择包裹符')
                return false;
            }
             var head_str_id = $('#head_str').find("option:checked").attr("id")
            if (head_str_id == 'def') {
                alert('请选择是否存在表头')
                return false;
            }
        console.log('manual_format')
        $.ajax({
            type: "POST",
            data: {
                'file_name': $('#file_parse').val(),
                'sheet_name': $('#sheet_list').val(),
                'cut_str': $('#cut_str').val(),
                'quote_str': $('#quote_str').val(),
                'head_str': $('#head_str').val()
            },
            url: "/oratk_app/oratk_most_sqlldr_manual_format_ajax", //后台处理函数的url
            cache: false,
            dataType: "html",
            beforeSend: function () {
                // $('#loadingModal').modal({backdrop: 'static', keyboard: false});
                showLoading()
                //$('#submit_id').button('loading')
            },
            complete: function () {
                //$('#loadingModal').modal('hide');
                hideLoading()
                //$('#submit_id').button('reset')
            },
            success: function (result) {
                if (result === 'ok') {
                    location.reload();
                } else {
                    alert('手工格式化出错，ERROR:\n' +
                        result);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest.status);
                alert(XMLHttpRequest.readyState);
                alert(textStatus);
            },
        })

    })
</script>